package com.digdes.calendar.dao.impl;

import com.digdes.calendar.dao.EventParticipantDAO;
import com.digdes.calendar.model.EventParticipant;
import com.digdes.calendar.model.impl.EventParticipantImpl;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import java.util.Set;

/**
 * User: Dmitry
 * Date: 15.04.12
 * Time: 0:00
 */
public class EventParticipantDAOImpl extends HibernateDaoSupport implements EventParticipantDAO {
    public void saveEventParticipant(EventParticipant e) {
        getHibernateTemplate().save(e);
    }

    public void updateEventParticipant(EventParticipant e) {
        getHibernateTemplate().update(e);
    }

    public void deleteEventParticipant(Long id) {
        Object eventparticipant = getHibernateTemplate().load(EventParticipantImpl.class, id);
        getHibernateTemplate().delete(eventparticipant);
    }

    public EventParticipant findEventParticipant(Long id) {
        return (EventParticipant) getHibernateTemplate().find("from EventParticipantImpl eventp where eventp.id=?", id);
    }

    public Set<EventParticipant> getAllEventParticipant() {
        return (Set<EventParticipant>) getHibernateTemplate().find("from EventParticipantImpl");
    }
}
